#include "debug.h"
#include "../DDIC/AllDDIC.h"
#include "usbd_cdc_core.h"

/********************************************************************************************
    Demura  Flashê1?ü
		Demura	Flash2á3y
		Demura	FlashD′è?
		Demura	FlashD￡?é
		Demura	Flash OTP
		Demura	1|?ü?a??&1?±?
********************************************************************************************
********************************************************************************************/
//{0xfe,0x26,0xf3,0x02,0x18,(USB_Rx_Demura_Total_Num>>16),0x19,(USB_Rx_Demura_Total_Num>>8),0x1A,USB_Rx_Demura_Total_Num};

void Enable_Flash_Control_and_SPI_Flash_En(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u16 tmp=0;
	u8 buffer1[3];	
	u8 RM67298_Enable_Flash_Control[4] = {0xfe, 0x20, 0xf3, 0x02};
	u8 RM67298_Enable_Flash_Read_REG[3] = {0xEA,0xEB,0xEC};
	u8 RM69350_Enable_Flash_Control[24] = {0xfe,0xd2,0x01,0xcf,0xfe,0x40,0x4d,0x20,0xfe,0xd2,0x05,0x18,0xfe,0x20,0xf3,0x08,0xf3,0x00,0xf3,0x04,0xf3,0x02,0xfe,0xe0};
	u8 RM69350_Enable_Flash_Read_REG[3] = {0x6d,0x6e,0x6f};	
	u8 RM692A9_Enable_Flash_Control[26] = {0xfe,0x26,0x04,0xcf,0x10,0x4b,0x14,0x22,0x1e,0x31,0xfe,0x20,0x5f,0x01,0x09,0x13,0xfe,0x26,0xf3,0x02,0x18,0x13,0x19,0x48,0x1A,0xf8};
	u8 RM692A9_Enable_Flash_Read_REG[3] = {0xEA,0xEB,0xEC};	
	
	u8 R66455_Enable_Flash_Control[52]={0x34,0xDF,0x00,0x40,0x58,0x83,0x2D,0x05,0x35,0x15,0x01,0x31,0x11,0x6B,0x50,0x00,0x02,0x00,0x00,0x43,0x84,0x00,0x10,0x00,0xDF,0xD4,0x0E,0x00,0x00,0x13,0xFF,0x8C,0x27,0x17,0x0F,0x00,0x55,0x18,0x0F,0x00,0x1A,0x0F,0x00,0x1C,0x0F,0x00,0x1E,0x0F,0x00,0x00,0x00,0x00}; 
	u8 R66455_RDID[7]={0x06,0xf3,0x9f,0x00,0x00,0x00,0x02};
	u8 R66456_Enable_Flash_Control[5]={0x05,0xDF,0x5F,0x00,0x5A};
	u8 R66456_RDID[10]={0x09,0xF3,0x9F,0x00,0x00,0x00,0x02,0x00,0xF4,0x00};	
	
	if(buffer[7] == RM692A9)	//297 298 299
	{
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
		delay_ms(15);
		for(i=0;i<sizeof(RM692A9_Enable_Flash_Control);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM692A9_Enable_Flash_Control[i];
			buffer1[2] = RM692A9_Enable_Flash_Control[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}
    SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
    SSD2828_W_Reg(SigMode,channel,0xBC,0x0001);	
    for( i = 0; i< 3;i++)			 	
    {  	
        SSD2828_W_Reg(SigMode,channel,0xC1,0x0001); //return package                           
        buffer1[0] = 0x01;
        buffer1[1] = RM692A9_Enable_Flash_Read_REG[i];
        SSD2828_W_Array(SigMode,channel,buffer1,0); 
				delay_ms(6);
        buffer[4+i]=SSD2828_R_Reg(SigMode,channel,0xFF);        
    }
		//buffer[2]=5;
	}
	else if(buffer[7] == RM67298)	//297 298 299
	{
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
		delay_ms(15);
		for(i=0;i<sizeof(RM67298_Enable_Flash_Control);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM67298_Enable_Flash_Control[i];
			buffer1[2] = RM67298_Enable_Flash_Control[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}
    SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
    SSD2828_W_Reg(SigMode,channel,0xBC,0x0001);	
    for( i = 0; i< 3;i++)			 	
    {  	
        SSD2828_W_Reg(SigMode,channel,0xC1,0x0001); //return package                           
        buffer1[0] = 0x01;
        buffer1[1] = RM67298_Enable_Flash_Read_REG[i];
        SSD2828_W_Array(SigMode,channel,buffer1,0); 
				delay_ms(6);
        buffer[4+i]=SSD2828_R_Reg(SigMode,channel,0xFF);        
    }	
		//buffer[2]=5;
	}
	else if(buffer[7] == RM69350)	//350
	{
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
		delay_ms(15);
		for(i=0;i<sizeof(RM69350_Enable_Flash_Control);i++)
		{
		buffer1[0] = 0x02;
		buffer1[1] = RM69350_Enable_Flash_Control[i];
		buffer1[2] = RM69350_Enable_Flash_Control[i+1];
		SSD2828_W_Array(SigMode,channel,buffer1,0);
		delay_ms(15);
		i+=1;
		}
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
		SSD2828_W_Reg(SigMode,channel,0xBC,0x0001); 
		for( i = 0; i< 3;i++)				
		{	
			SSD2828_W_Reg(SigMode,channel,0xC1,0x0001); //return package						   
			buffer1[0] = 0x01;
			buffer1[1] = RM69350_Enable_Flash_Read_REG[i];
			SSD2828_W_Array(SigMode,channel,buffer1,0); 
			delay_ms(6);
			buffer[4+i]=SSD2828_R_Reg(SigMode,channel,0xFF);		
		}
	}
	else if(buffer[7] == R66455)	
	{
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);		
    delay_ms(5);
		buffer1[0] = 0x02;
		buffer1[1] = 0xB0;
		buffer1[2] = 0x00;
		SSD2828_W_Array(SigMode,channel,buffer1,0);
		delay_ms(2);
		SSD2828_W_Array(SigMode,channel,R66456_Enable_Flash_Control,0);
		delay_ms(2);
		SSD2828_W_Array(SigMode,channel,R66456_RDID,0);
		delay_ms(2);
		buffer1[1] = 0xf2;
		buffer1[2] = 0x09;
		SSD2828_W_Array(SigMode,channel,buffer1,0);
		delay_ms(15);
    SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080);                               
    SSD2828_W_Reg(SigMode,channel,0xC1,0x0003); //return package size                                
    SSD2828_W_Reg(SigMode,channel,0xC0,0x0001); //reset
	
    buffer1[0] = 0x01;
    buffer1[1] = 0xf4; 	//download register 
    SSD2828_W_Array(SigMode,channel,buffer1,0);
    delay_ms(5);  
    SSD2828_W_Reg(SigMode,channel,0xD4,0x00FA);
    SSD2828_W_Cmd(SigMode,channel,0xFF);

    for(i=0;i<3;i++)  //data read out length
    {
        SSD2828_W_Cmd(SigMode,channel,0xFA);		
        tmp=SPI3_Read_u16_Data(channel);
        buffer[4+i]=tmp>>8;
        buffer[5+i]=tmp;
        delay_ms(5);
        i++;
    }
		buffer[7]=0x30;
	}	
	else if(buffer[7] == NT37700C)
	{
			NT37700C_QE1(pdev,ep_addr,SigMode,channel,buffer,LP_B7_Data,HS_B7_Data);
	}		
	delay_ms(5);
	SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
	STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);           //·μ?? ?áè?μ? Gammaêy?Y  ￡ook  
}
void Inter_Demura_Ram(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u8 buffer1[3];
	u8 RM67298_Inter_Demura_Ram_Cmd_Table[26]={0xfe,0x40,0x0e,0x80,0xfe,0x20,0xb1,0x00,0xfe,0xd0,0x55,0x30,0x07,0x01,0xfe,0x40,0x0e,0x50,0xfe,0xd0,0x42,0x81,0x27,0x55,0xfe,0x00};
	u8 RM69350_Inter_Demura_Ram_Cmd_Table[22]={0xfe,0x40,0x0e,0x80,0xfe,0xd2,0x18,0x55,0xfe,0xd0,0x03,0x09,0x4d,0x01,0x78,0x01,0xfe,0x40,0x10,0x82,0xfe,0x00};	
	u8 RM692A9_Inter_Demura_Ram_Cmd_Table[28]={0xfe,0xA0,0x0B,0x11,0xfe,0xd0,0x58,0x53,0x07,0x8D,0x42,0x81,0x55,0x58,0xFE,0xD2,0x6E,0x20,0xFE,0x40,0x5B,0x01,0x5E,0x40,0x0E,0x40,0xfe,0x00};		
	SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
	delay_ms(15);
		
	if(buffer[7] == RM692A9)	//297 298 299
	{	
		for(i=0;i<sizeof(RM692A9_Inter_Demura_Ram_Cmd_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM692A9_Inter_Demura_Ram_Cmd_Table[i];
			buffer1[2] = RM692A9_Inter_Demura_Ram_Cmd_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(15);
			i+=1;
		}	
	}	
	else if(buffer[7] == RM67298)	//297 298 299
	{	
		for(i=0;i<sizeof(RM67298_Inter_Demura_Ram_Cmd_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM67298_Inter_Demura_Ram_Cmd_Table[i];
			buffer1[2] = RM67298_Inter_Demura_Ram_Cmd_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(15);
			i+=1;
		}	
	}
	else if(buffer[7] == RM69350)	//350
	{
		for(i=0;i<sizeof(RM69350_Inter_Demura_Ram_Cmd_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM69350_Inter_Demura_Ram_Cmd_Table[i];
			buffer1[2] = RM69350_Inter_Demura_Ram_Cmd_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(15);
			i+=1;
		}		
	}
	else if(buffer[7] == R66455)	//350
	{
			R66456_Flash_Write_En_Demura(pdev,SigMode,channel);
	}
	else if(buffer[7] == NT37700C)
	{
			NT37700C_Program_Flash_Set(pdev,ep_addr,SigMode,channel,buffer,LP_B7_Data,HS_B7_Data);
	}
  buffer[0] = 0x2F;
	buffer[1] = 0x01;		

	SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
	STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);        																					
}
                                    
void Exit_Demura_Ram(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u8 buffer1[3];
	u8 RM67298_Exit_Demura_Ram_Cmd_Table[24]={0xfe,0x40,0x0e,0x80,0xfe,0x20,0xb1,0x00,0xfe,0xd0,0x55,0x00,0x07,0x01,0xfe,0x40,0x0e,0x50,0xfe,0xd0,0x42,0x01,0x27,0x55};
	SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
	delay_ms(15);
	for(i=0;i<sizeof(RM67298_Exit_Demura_Ram_Cmd_Table);i++)
	{
		buffer1[0] = 0x02;
		buffer1[1] = RM67298_Exit_Demura_Ram_Cmd_Table[i];
		buffer1[2] = RM67298_Exit_Demura_Ram_Cmd_Table[i+1];
		SSD2828_W_Array(SigMode,channel,buffer1,0);
		delay_ms(5);
		i+=1;
	}	
  buffer[0] = 0x2F;
	buffer[1] = 0x02;		

	SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
	STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);           //·μ?? ?áè?μ? Gammaêy?Y  ￡ook  
}
                               
void Flash_Write_Demura(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
		u32 error_times=0;
		u8 buffer1[3];
		u8 RM67298_Flash_Write_Demura_data_Table[20]={0xfe,0x20,0xf2,0x04,0xb1,0x00,0xab,0x00,0xac,0x00,0xad,0x00,0xae,0x1a,0xaf,0xb3,0xb0,0x62,0xf2,0x10};
		u8 RM692A9_Flash_Write_Demura_data_Table[14]={0xfe,0x26,0x1B,0x00,0xF2,0x04,0x15,0x00,0x16,0x00,0x17,0x00,0xF2,0x10};
			
		u8 RM69350_Flash_Write_Demura_data_Table[24]={0xfe,0x20,0xf2,0x04,0xfe,0xd2,0x18,0x55,0x12,0x00,0x13,0x00,0x14,0x00,0x15,0x17,0x16,0xff,0x17,0xff,0xfe,0x20,0xf2,0x10};		
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
		delay_ms(15);	
		if(OLED.H_pixel == 1080 && OLED.V_pixel == 2160)	//599 601 inch
		{
			RM67298_Flash_Write_Demura_data_Table[13] = 0x1a;
			RM67298_Flash_Write_Demura_data_Table[15] = 0xb3;
			RM67298_Flash_Write_Demura_data_Table[17] = 0x62;
			//u8 RM67298_Flash_Write_Demura_data_Table[20]={0xfe,0x20,0xf2,0x04,0xb1,0x00,0xab,0x00,0xac,0x00,0xad,0x00,0xae,0x1a,0xaf,0xb3,0xb0,0x62,0xf2,0x10};
		}
		else if(OLED.H_pixel == 1080 && OLED.V_pixel == 2248)	//621 inch
		{
			RM67298_Flash_Write_Demura_data_Table[13] = 0x1b;
			RM67298_Flash_Write_Demura_data_Table[15] = 0xc9;
			RM67298_Flash_Write_Demura_data_Table[17] = 0xd2;
			//u8 RM67298_Flash_Write_Demura_data_Table[20]={0xfe,0x20,0xf2,0x04,0xb1,0x00,0xab,0x00,0xac,0x00,0xad,0x00,0xae,0x1b,0xaf,0xc9,0xb0,0xd2,0xf2,0x10};
		}
//----------------------------------------------------------------------RM67298			
		if(buffer[7] == RM67298)	//297 298 299
		{			
			for(i=0;i<sizeof(RM67298_Flash_Write_Demura_data_Table);i++)
			{
				buffer1[0] = 0x02;
				buffer1[1] = RM67298_Flash_Write_Demura_data_Table[i];
				buffer1[2] = RM67298_Flash_Write_Demura_data_Table[i+1];
				SSD2828_W_Array(SigMode,channel,buffer1,0);
				delay_ms(5);
				i+=1;
			}	
			SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
			SSD2828_W_Reg(SigMode,channel,0xBC,0x0001);	
			SSD2828_W_Reg(SigMode,channel,0xC1,0x0002); //return package  
			do
			{                        
					buffer1[0] = 0x01;
					buffer1[1] = 0xE8;
					SSD2828_W_Array(SigMode,channel,buffer1,0); 
					delay_ms(6);
					buffer[4]=SSD2828_R_Reg(SigMode,channel,0xFF);   
					delay_ms(100);
			}while((buffer[4]&0x80)!=0x80);
			delay_ms(5);
			buffer[0] = 0x2F;
			buffer[1] = 0x03;		
			buffer[4] = 0x80;				
		}
		else if(buffer[7] == RM692A9)	//29x
		{			
			for(i=0;i<sizeof(RM692A9_Flash_Write_Demura_data_Table);i++)
			{
				buffer1[0] = 0x02;
				buffer1[1] = RM692A9_Flash_Write_Demura_data_Table[i];
				buffer1[2] = RM692A9_Flash_Write_Demura_data_Table[i+1];
				SSD2828_W_Array(SigMode,channel,buffer1,0);
				delay_ms(15);
				i+=1;
			}	
			delay_ms(500);
			SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
			SSD2828_W_Reg(SigMode,channel,0xBC,0x0001);	
			SSD2828_W_Reg(SigMode,channel,0xC1,0x0002); //return package  
			do
			{                        
					buffer1[0] = 0x01;
					buffer1[1] = 0xDB;
					SSD2828_W_Array(SigMode,channel,buffer1,0); 
					delay_ms(6);
					buffer[4]=SSD2828_R_Reg(SigMode,channel,0xFF);   
					delay_ms(100);
			}while((buffer[4]&0x80)!=0x80);
			delay_ms(5);
			buffer[0] = 0x2F;
			buffer[1] = 0x03;		
			buffer[4] = 0x80;				
		}		
		
//----------------------------------------------------------------------RM69350			
		else if(buffer[7] == RM69350) //350
		{
			buffer[0] = 0x2F;
			buffer[1] = 0x03;		
			buffer[4] = 0x08;	
			
			for(i=0;i<sizeof(RM69350_Flash_Write_Demura_data_Table);i++)
			{
				buffer1[0] = 0x02;
				buffer1[1] = RM69350_Flash_Write_Demura_data_Table[i];
				buffer1[2] = RM69350_Flash_Write_Demura_data_Table[i+1];
				SSD2828_W_Array(SigMode,channel,buffer1,0);
				delay_ms(100);
				i+=1;
			}	
			delay_ms(500);
			
			buffer1[0] = 0x02;
			buffer1[1] = 0xfe;
			buffer1[2] = 0xe0;
			SSD2828_W_Array(SigMode,channel,buffer1,0);			
			delay_ms(5);
		//	SSD2828_W_Reg(SigMode,channel,0xB7,((HS_B7_Data|0x0010)&0XFFFD)|0x0080);  //bit7 1:?á2ù×÷ bit4 1￡oHS CLOCK Disable
			SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
			delay_ms(15);
			SSD2828_W_Reg(SigMode,channel,0xC1,0x0002); //return package  
			do
			{                        
					buffer1[0] = 0x01;
					buffer1[1] = 0x6B;
					SSD2828_W_Array(SigMode,channel,buffer1,0); 
					delay_ms(20);
					buffer[4]=SSD2828_R_Reg(SigMode,channel,0xFF);   
					delay_ms(50);
					if((++error_times)>300)//15sec timeout error
					{
						buffer[4] = 0x00;	
						goto error_tips0;
					}				
			}while(buffer[4]!=0x08);	
		}
		else if(buffer[7] == NT37700C)
		{
			NT37700C_Program_Flash_Load(pdev,ep_addr,SigMode,channel,buffer,LP_B7_Data,HS_B7_Data);
		}
	error_tips0:
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);		
}                       

void Flash_Write_Demura2(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u32 error_time=0;
	u8 buffer1[3];
	USB_Rx_Demura_Total_Num+=0x180000;
	u8 RM69350_Flash_Write_Demura_data_Table2[24]={0xfe,0x20,0xf2,0x04,0xfe,0xd2,0x18,0x55,0x12,0x18,0x13,0x00,0x14,0x00,0x15,(USB_Rx_Demura_Total_Num>>16),0x16,(USB_Rx_Demura_Total_Num>>8),0x17,(USB_Rx_Demura_Total_Num),0xfe,0x20,0xf2,0x10}; //7d		
		
	SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
	//SSD2828_W_Reg(SigMode,channel,0xB7,(HS_B7_Data|0x0010)&0XFFfd);		
	delay_ms(15);		
	if(buffer[7] == RM69350)	//350
	{		
		buffer[0] = 0x2F;
		buffer[1] = 0x0A;		
		buffer[4] = 0x08;	
		for(i=0;i<sizeof(RM69350_Flash_Write_Demura_data_Table2);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM69350_Flash_Write_Demura_data_Table2[i];
			buffer1[2] = RM69350_Flash_Write_Demura_data_Table2[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(100);
			i+=1;
		}	
		//------------------------------------------------------------- 
		delay_ms(500);
		
		buffer1[0] = 0x02;
		buffer1[1] = 0xfe;
		buffer1[2] = 0xe0;
		SSD2828_W_Array(SigMode,channel,buffer1,0);			
		delay_ms(50);		
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080);
			delay_ms(15);		
		//SSD2828_W_Reg(SigMode,channel,0xB7,((HS_B7_Data|0x0010)&0XFFFD)|0x0080);  //bit7 1:?á2ù×÷ bit4 1￡oHS CLOCK Disable
		SSD2828_W_Reg(SigMode,channel,0xBC,0x0001); 
		SSD2828_W_Reg(SigMode,channel,0xC1,0x0002); //return package  
		
		do
		{						 
			buffer1[0] = 0x01;
			buffer1[1] = 0x6B;
			SSD2828_W_Array(SigMode,channel,buffer1,0); 
			delay_ms(20);
			buffer[4]=SSD2828_R_Reg(SigMode,channel,0xFF);	 
			delay_ms(50);
			if((++error_time)>300)//15sec timeout error
			{
				buffer[4] = 0x00;	
				goto error_tips1;
			}
		}while((buffer[4]&0x08)!=0x08);	
		
	error_tips1:
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);
	}
}


void Flash_Check_Demura(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u16 tmp=0;
	u8 buffer1[3];
	u8 RM67298_Flash_Check_Read_REG[2]={0xE6,0xE7};
	u8 RM67298_Flash_Check_Demura_data_Table[18]={0xfe,0x20,0xf2,0x04,0xab,0x00,0xac,0x00,0xad,0x00,0xae,0x1a,0xaf,0xb3,0xb0,0x62,0xf2,0x01};	
	u8 RM692A9_Flash_Check_Read_REG[2]={0xE6,0xE7};
	u8 RM692A9_Flash_Check_Demura_data_Table[10]={0xfe,0x26,0x18,0x13,0x19,0x48,0x1A,0xF4,0xF2,0x01};
	u8 RM69350_Flash_Check_Read_REG[2]={0x69,0x6a};
	u8 RM69350_Flash_Check_Demura_data_Table[36]={0xfe,0xd2,0x06,0x03,0xfe,0x20,0xf3,0x08,0xf3,0x00,0xf3,0x04,0xf3,0x02,0xfe,0x20,0xf2,0x04,0xfe,0xd2,0x12,0x00,0x13,0x00,0x14,0x00,0x15,(USB_Rx_Demura_Total_Num>>16),0x16,(USB_Rx_Demura_Total_Num>>8),0x17,(USB_Rx_Demura_Total_Num-0x0b),0xfe,0x20,0xf2,0x01};	
	
	SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
	delay_ms(15);
	if(OLED.H_pixel == 1080 && OLED.V_pixel == 2160)	//599 601 inch
	{
		RM67298_Flash_Check_Demura_data_Table[11] =0x1a;
		RM67298_Flash_Check_Demura_data_Table[13] =0xb3;
		RM67298_Flash_Check_Demura_data_Table[15] =0x62;
		//u8 RM67298_Flash_Check_Demura_data_Table[18]={0xfe,0x20,0xf2,0x04,0xab,0x00,0xac,0x00,0xad,0x00,0xae,0x1a,0xaf,0xb3,0xb0,0x62,0xf2,0x01};
	}
	else if(OLED.H_pixel == 1080 && OLED.V_pixel == 2248)	//621 inch
	{
		RM67298_Flash_Check_Demura_data_Table[11] =0x1b;
		RM67298_Flash_Check_Demura_data_Table[13] =0xc9;
		RM67298_Flash_Check_Demura_data_Table[15] =0xd2;
		//u8 RM67298_Flash_Check_Demura_data_Table[18]={0xfe,0x20,0xf2,0x04,0xab,0x00,0xac,0x00,0xad,0x00,0xae,0x1b,0xaf,0xc9,0xb0,0xd2,0xf2,0x01};
	}
		
	if(buffer[7] == 0x2E)	//297 298 299
	{
		for(i=0;i<sizeof(RM67298_Flash_Check_Demura_data_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM67298_Flash_Check_Demura_data_Table[i];
			buffer1[2] = RM67298_Flash_Check_Demura_data_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}	
		delay_ms(200);
	
    SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
    SSD2828_W_Reg(SigMode,channel,0xBC,0x0001);		
    for( i = 0;i<sizeof(RM67298_Flash_Check_Read_REG);i++)			 	
    {  	
        SSD2828_W_Reg(SigMode,channel,0xC1,0x0001); //return package                           
        buffer1[0] = 0x01;
        buffer1[1] = RM67298_Flash_Check_Read_REG[i];
        SSD2828_W_Array(SigMode,channel,buffer1,0); 
				delay_ms(6);
        buffer[4+i]=SSD2828_R_Reg(SigMode,channel,0xFF);        
    }			
	}
	if(buffer[7] == RM692A9)	//297 298 299
	{
		for(i=0;i<sizeof(RM692A9_Flash_Check_Demura_data_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM692A9_Flash_Check_Demura_data_Table[i];
			buffer1[2] = RM692A9_Flash_Check_Demura_data_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}	
		delay_ms(500);
	
    SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
    SSD2828_W_Reg(SigMode,channel,0xBC,0x0001);		
    for( i = 0;i<sizeof(RM692A9_Flash_Check_Read_REG);i++)			 	
    {  	
        SSD2828_W_Reg(SigMode,channel,0xC1,0x0001); //return package                           
        buffer1[0] = 0x01;
        buffer1[1] = RM692A9_Flash_Check_Read_REG[i];
        SSD2828_W_Array(SigMode,channel,buffer1,0); 
				delay_ms(6);
        buffer[4+i]=SSD2828_R_Reg(SigMode,channel,0xFF);        
    }			
	}	
	
//----------------------------------------------------------------	
	else if(buffer[7] == RM69350)	//350
	{
		for(i=0;i<sizeof(RM69350_Flash_Check_Demura_data_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM69350_Flash_Check_Demura_data_Table[i];
			buffer1[2] = RM69350_Flash_Check_Demura_data_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(6);
			i+=1;
		}	
		delay_ms(1200);
		
		buffer1[0] = 0x02;
		buffer1[1] = 0xfe;
		buffer1[2] = 0xe0;
		SSD2828_W_Array(SigMode,channel,buffer1,0);			
		delay_ms(15);		
		
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
		SSD2828_W_Reg(SigMode,channel,0xBC,0x0001); 	
		for(i=0;i<sizeof(RM69350_Flash_Check_Read_REG);i++) 			
		{	
			SSD2828_W_Reg(SigMode,channel,0xC1,0x0001); //return package						   
			buffer1[0] = 0x01;
			buffer1[1] = RM69350_Flash_Check_Read_REG[i];
			SSD2828_W_Array(SigMode,channel,buffer1,0); 
			delay_ms(6);
			buffer[4+i]=SSD2828_R_Reg(SigMode,channel,0xFF);		
		}			
	}
	else if(buffer[7] == R66455)	
	{
		SSD2828_W_Reg(SigMode,channel,0xB7,(HS_B7_Data|0x0410)&0XFFFD);		
    delay_ms(5);
		buffer1[0] = 0x02;
		buffer1[1] = 0xB0;
		buffer1[2] = 0x04;
		SSD2828_W_Array(SigMode,channel,buffer1,0);
		delay_ms(2);
    SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080);                               
    SSD2828_W_Reg(SigMode,channel,0xC1,0x0008); //return package size                                
    SSD2828_W_Reg(SigMode,channel,0xC0,0x0001); //reset
	
    buffer1[0] = 0x01;
    buffer1[1] = 0xE7; 	//download register 
    SSD2828_W_Array(SigMode,channel,buffer1,0);
    delay_ms(5);  
    SSD2828_W_Reg(SigMode,channel,0xD4,0x00FA);
    SSD2828_W_Cmd(SigMode,channel,0xFF);
    for(i=0;i<8;i++)  //data read out length     R66456 6&7   R66456 2&3
    {
        SSD2828_W_Cmd(SigMode,channel,0xFA);		
        tmp=SPI3_Read_u16_Data(channel);
        buffer[4+i]=tmp>>8;
        buffer[5+i]=tmp;
        delay_ms(5);
        i++;
    }
		buffer[4]=buffer[9];   //5
		buffer[5]=buffer[10];  //6
		buffer[7]=0x30;
	}
	
	  delay_ms(5);
		buffer[0] = 0x2F;
		buffer[1] = 0x04;					
    SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
    STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);           //·μ?? ?áè?μ? Gammaêy?Y  ￡ook  	
}
                                  
void Flash_Erase_Demura(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u8 buffer1[3];
	u8 RM67298_Flash_Erase_Demura_data_Table[8]={0xfe,0x20,0xf2,0x04,0xb1,0x00,0xf3,0x01};
	u8 RM69350_Flash_Erase_Demura_data_Table[10]={0xfe,0xd2,0x18,0x55,0xfe,0x20,0xf2,0x04,0xf3,0x01};
	u8 RM692A9_Flash_Erase_Demura_data_Table[8]={0xfe,0x26,0x1B,0x00,0xF2,0x04,0xf3,0x01};
	
	u8 RM67298_Read_REG=0xE8;
	u8 RM69350_Read_REG=0x6B;	
	u8 RM692A9_Read_REG=0xDB;	
	
	SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
	delay_ms(15);
	
  if(buffer[7] == RM692A9)	//2AX
	{
		for(i=0;i<sizeof(RM692A9_Flash_Erase_Demura_data_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM692A9_Flash_Erase_Demura_data_Table[i];
			buffer1[2] = RM692A9_Flash_Erase_Demura_data_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}
    SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
    SSD2828_W_Reg(SigMode,channel,0xBC,0x0001);	
		SSD2828_W_Reg(SigMode,channel,0xC1,0x0002); //return package  
    do
		{                        
        buffer1[0] = 0x01;
        buffer1[1] = RM692A9_Read_REG;
        SSD2828_W_Array(SigMode,channel,buffer1,0); 
				delay_ms(6);
        buffer[4]=SSD2828_R_Reg(SigMode,channel,0xFF);      
    }while((buffer[4]&0x80)!=0x80);
    delay_ms(5);
		buffer[0] = 0x2F;
		buffer[1] = 0x05;		
		buffer[4] = 0x80;	
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);           //êy?Y3¤?è-crcá?×??ú			
	}		
	else if(buffer[7] == RM67298)	//297 298 299
	{
		for(i=0;i<sizeof(RM67298_Flash_Erase_Demura_data_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM67298_Flash_Erase_Demura_data_Table[i];
			buffer1[2] = RM67298_Flash_Erase_Demura_data_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}
    SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
    SSD2828_W_Reg(SigMode,channel,0xBC,0x0001);	
		SSD2828_W_Reg(SigMode,channel,0xC1,0x0002); //return package  
    do
		{                        
        buffer1[0] = 0x01;
        buffer1[1] = RM67298_Read_REG;
        SSD2828_W_Array(SigMode,channel,buffer1,0); 
				delay_ms(6);
        buffer[4]=SSD2828_R_Reg(SigMode,channel,0xFF);      
    }while((buffer[4]&0x80)!=0x80);
    delay_ms(5);
		buffer[0] = 0x2F;
		buffer[1] = 0x05;		
		buffer[4] = 0x80;	
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);           //êy?Y3¤?è-crcá?×??ú	
	}
	else if(buffer[7] == RM69350)	//350
	{	
		for(i=0;i<sizeof(RM69350_Flash_Erase_Demura_data_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM69350_Flash_Erase_Demura_data_Table[i];
			buffer1[2] = RM69350_Flash_Erase_Demura_data_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(6);
			i+=1;
		}
		delay_ms(5000);	
		buffer1[0] = 0x02;
		buffer1[1] = 0xfe;
		buffer1[2] = 0xe0;
		SSD2828_W_Array(SigMode,channel,buffer1,0);			
		delay_ms(15);		
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
		SSD2828_W_Reg(SigMode,channel,0xBC,0x0001); 
		SSD2828_W_Reg(SigMode,channel,0xC1,0x0002); //return package  
		do
		{						 
			buffer1[0] = 0x01;
			buffer1[1] = RM69350_Read_REG;
			SSD2828_W_Array(SigMode,channel,buffer1,0); 
			delay_ms(6);
			buffer[4]=SSD2828_R_Reg(SigMode,channel,0xFF);		
		}while((buffer[4]&0x08)!=0x08);
		delay_ms(5);
		buffer[0] = 0x2F;
		buffer[1] = 0x05;		
		buffer[4] = 0x08;		
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);           //êy?Y3¤?è-crcá?×??ú			
	}
	else if(buffer[7] == R66455)
	{
		 R66456_Flash_Erase_Demura(pdev,SigMode,channel);
		
		buffer[7] = 0x30;
		buffer[1] = 0x05;	
		buffer[4] = 0x00;		
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);           //êy?Y3¤?è-crcá?×??ú	
	}
	else if(buffer[7] == NT37700C)
	{
		NT37700C_Erase_Flash(pdev,ep_addr,SigMode,channel,buffer,LP_B7_Data,HS_B7_Data);	
		buffer[7] = 0x4E;
		buffer[1] = 0x05;	
		buffer[4] = 0x00;		
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);           //êy?Y3¤?è-crcá?×??ú	
	}
}

void Flash_Demura_OTP(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
#if 1
	  u8 buffer1[3];
		u8 RM67298_Flash_Demura_OTP_Table[18]={0xfe,0x00,0x28,0x00,0x10,0x00,0xfe,0x40,0xf8,0x02,0xf2,0x01,0xf3,0xa5,0xf4,0x5a,0xf5,0x3c};
		u8 Read_REG=0xE8;
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
		delay_ms(15);

		for(i=0;i<sizeof(RM67298_Flash_Demura_OTP_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM67298_Flash_Demura_OTP_Table[i];
			buffer1[2] = RM67298_Flash_Demura_OTP_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}
    delay_ms(5);
		buffer[0] = 0x2F;
		buffer[1] = 0x09;

    SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
    STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);           //·μ?? ?áè?μ? Gammaêy?Y  ￡ook  
#endif
}

void Demura_Function_ON(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u8 buffer1[7];
	u8 RM67298_Demura_Function_ON_Table[10]={0xfe,0x20,0x09,0x10,0xA6,0xC0,0xA7,0xFF,0xBC,0x01};
	u8 RM69350_Demura_Function_ON_Table[8] = {0xfe, 0xd2, 0x0e, 0xc0, 0x0f, 0x7f, 0xAA, 0x01};
	u8 RM692A9_Demura_Function_ON_Table[4] = {0xfe, 0x22, 0x77, 0x00};
	
	SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
	delay_ms(15);	
	
	if(buffer[7] == RM67298)	//297 298 299
	{
		for(i=0;i<sizeof(RM67298_Demura_Function_ON_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM67298_Demura_Function_ON_Table[i];
			buffer1[2] = RM67298_Demura_Function_ON_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}
	}
	else if(buffer[7] == RM692A9)	//297 298 299
	{
		for(i=0;i<sizeof(RM692A9_Demura_Function_ON_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM692A9_Demura_Function_ON_Table[i];
			buffer1[2] = RM692A9_Demura_Function_ON_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}
	}	
	else if(buffer[7] == RM69350)	//350
	{
		for(i=0;i<sizeof(RM69350_Demura_Function_ON_Table);i++)
		{
		buffer1[0] = 0x02;
		buffer1[1] = RM69350_Demura_Function_ON_Table[i];
		buffer1[2] = RM69350_Demura_Function_ON_Table[i+1];
		SSD2828_W_Array(SigMode,channel,buffer1,0);
		delay_ms(50);
		i+=1;
		}
	}
	else if(buffer[7] == R66455)
	{
		buffer1[0] = 0x02;
		buffer1[1] = 0xB0;
		buffer1[2] = 0x80;
		SSD2828_W_Array(SigMode,channel,buffer1,0);
		buffer1[1] = 0xD4;
		buffer1[2] = 0x93;
		SSD2828_W_Array(SigMode,channel,buffer1,0);		
	}
	else if(buffer[7] == NT37700C)//(Demura off)
	{
		buffer1[0] = 0x06;
		buffer1[1] = 0xF0;
		buffer1[2] = 0x55;
		buffer1[3] = 0xAA;
		buffer1[4] = 0x52;
		buffer1[5] = 0x08;
		buffer1[6] = 0x04;
		SSD2828_W_Array(SigMode,channel,buffer1,0);
		buffer1[0] = 0x06;
		buffer1[1] = 0xD0;
		buffer1[2] = 0x00;
		buffer1[3] = 0x1F;
		buffer1[4] = 0x00;
		buffer1[5] = 0x00;
		buffer1[6] = 0x80; 
		SSD2828_W_Array(SigMode,channel,buffer1,0);
	}
	delay_ms(5);
	buffer[0] = 0x2F;
	buffer[1] = 0x07;		
	SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
	STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);           //êy?Y3¤?è-crcá?×??ú
}

void Demura_Function_OFF(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u8 buffer1[7];
	u8 RM67298_Demura_Function_OFF_Table[10]={0xfe,0x20,0x09,0x10,0xA6,0xC0,0xA7,0xFF,0xBC,0x81};
	u8 RM69350_Demura_Function_OFF_Table[8] = {0xfe,0xd2,0x0e,0xc0,0x0f,0x7f,0xAA,0x81};
	u8 RM692A9_Demura_Function_OFF_Table[4] = {0xfe, 0x22, 0x77, 0x04};	
	
	SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
	delay_ms(15);

	if(buffer[7] == RM67298)	//297 298 299
	{
		for(i=0;i<sizeof(RM67298_Demura_Function_OFF_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM67298_Demura_Function_OFF_Table[i];
			buffer1[2] = RM67298_Demura_Function_OFF_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}
	}
	else if(buffer[7] == RM692A9)	//
	{
		for(i=0;i<sizeof(RM692A9_Demura_Function_OFF_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM692A9_Demura_Function_OFF_Table[i];
			buffer1[2] = RM692A9_Demura_Function_OFF_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}
	}	
	else if(buffer[7] == RM69350)	//350
	{
		for(i=0;i<sizeof(RM69350_Demura_Function_OFF_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM69350_Demura_Function_OFF_Table[i];
			buffer1[2] = RM69350_Demura_Function_OFF_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(50);
			i+=1;
		}
	}
	else if(buffer[7] == R66455)
	{
		buffer1[0] = 0x02;
		buffer1[1] = 0xB0;
		buffer1[2] = 0x80;
		SSD2828_W_Array(SigMode,channel,buffer1,0);
		buffer1[1] = 0xD4;
		buffer1[2] = 0x90;
		SSD2828_W_Array(SigMode,channel,buffer1,0);		
	}
	else if(buffer[7] == NT37700C)//(Demura off)
	{
		buffer1[0] = 0x06;
		buffer1[1] = 0xF0;
		buffer1[2] = 0x55;
		buffer1[3] = 0xAA;
		buffer1[4] = 0x52;
		buffer1[5] = 0x08;
		buffer1[6] = 0x04;
		SSD2828_W_Array(SigMode,channel,buffer1,0);
		buffer1[0] = 0x06;
		buffer1[1] = 0xD0;
		buffer1[2] = 0x00;
		buffer1[3] = 0x1F;
		buffer1[4] = 0x00;
		buffer1[5] = 0x00;
		buffer1[6] = 0x00; 
		SSD2828_W_Array(SigMode,channel,buffer1,0);
	}
	
	delay_ms(5);
	buffer[0] = 0x2F;  //Demura_type
	buffer[1] = 0x08;				
	SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
	STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);           //·μ?? ?áè?μ? Gammaêy?Y  ￡ook  
}

void ProcessForIc2F( USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8 buffer[],u16 LP_B7_Data,u16 HS_B7_Data)
{	
	switch(USB_Rx_Buffer[1])
	{
			case 0x01:                                      //写寄存器
					Inter_Demura_Ram(pdev,CDC_IN_EP,OLED.SigMode ,channel,USB_Rx_Buffer,LP_B7_Data,HS_B7_Data);
			break;	
			case 0x02:                                      //读寄存器
					Exit_Demura_Ram(pdev,CDC_IN_EP,OLED.SigMode ,channel,USB_Rx_Buffer,LP_B7_Data,HS_B7_Data);
			break;						 
			case 0x03:                                      //读寄存器
					Flash_Write_Demura(pdev,CDC_IN_EP,OLED.SigMode ,channel,USB_Rx_Buffer,LP_B7_Data,HS_B7_Data);
			break;	
			case 0x04:                                      //读寄存器
					Flash_Check_Demura(pdev,CDC_IN_EP,OLED.SigMode ,channel,USB_Rx_Buffer,LP_B7_Data,HS_B7_Data);
			break;												
			case 0x05:                                      //读寄存器
					Flash_Erase_Demura(pdev,CDC_IN_EP,OLED.SigMode ,channel,USB_Rx_Buffer,LP_B7_Data,HS_B7_Data);
			break;
			case 0x06:                                      //check flash ID
					Enable_Flash_Control_and_SPI_Flash_En(pdev,CDC_IN_EP,OLED.SigMode ,channel,USB_Rx_Buffer,LP_B7_Data,HS_B7_Data);
			break;	
			case 0x07:                                      //check flash ID
					Demura_Function_ON(pdev,CDC_IN_EP,OLED.SigMode ,channel,USB_Rx_Buffer,LP_B7_Data,HS_B7_Data);
			break;	
			case 0x08:                                      //check flash ID
					Demura_Function_OFF(pdev,CDC_IN_EP,OLED.SigMode ,channel,USB_Rx_Buffer,LP_B7_Data,HS_B7_Data);
			break;													
			case 0x0A:
					Flash_Write_Demura2(pdev,CDC_IN_EP,OLED.SigMode ,channel,USB_Rx_Buffer,LP_B7_Data,HS_B7_Data);
			break;
			default:
				break;												
	}
}
//********************************************************************************************